﻿using ExDUIR.NET.Declaration;
using ExDUIR.NET.Handle;

namespace ExDUIR.NET.Easing
{
    public class ExEasing
    {
        private readonly ExEasingHandle _handle;
        public bool IsValid => _handle.IsInvalid;
        public IntPtr Handle => _handle.Handle;
        internal ExEasing(ExEasingHandle handle)
        {
            _handle = handle;
        }

        internal ExEasing(int dwType, IntPtr pEasingContext, int dwMode, IntPtr pContext, int nTotalTime, int nInterval, int nState, int nStart, int nStop, IntPtr param1 = default, IntPtr param2 = default, IntPtr param3 = default, IntPtr param4 = default)
        {
            _handle = new ExEasingHandle(ExAPI._easing_create(dwType, pEasingContext, dwMode, pContext, nTotalTime, nInterval, nState, nStart, nStop,  param1, param2, param3, param4));
        }

        internal ExEasing(int dwType, IntPtr pEasingContext, int dwMode, ExEasingProcDelegate pContext, int nTotalTime, int nInterval, int nState, int nStart, int nStop, IntPtr param1 = default, IntPtr param2 = default, IntPtr param3 = default, IntPtr param4 = default)
        {
            _handle = new ExEasingHandle(ExAPI._easing_create(dwType, pEasingContext, dwMode, pContext, nTotalTime, nInterval, nState, nStart, nStop, param1, param2, param3, param4));
        }


        public int State
        {
            get
            {
                return ExAPI._easing_getstate(_handle.Handle);
            }
            set
            {
                ExAPI._easing_setstate(_handle.Handle, value);
            }
        }

        public void Dispose() => _handle.Dispose();
    }
}
